const GET = 'GET';
const POST = 'POST';

function request(method, url, data) {
	return new Promise(function(resolve, reject) {
		let header = {
			'content-type': 'application/json',
		};
		uni.request({
			url: url,
			method: method,
			data: method === POST ? JSON.stringify(data) : data,
			header: header,
			success(res) {
				// 请求成功
				console.log(res);
				if (res.data.code == 0 || res.data.code == 200) {
					resolve(res.data); // 返回数据部分
				} else {
					// 其他错误
					reject('运行出错,请稍后再试');
				}
			},
			fail(err) {
				// 请求失败
				reject(err);
			}
		});
	});
}

// 接口集合
const API = {
	GetOrder: (orderNo) => request(GET,
		'https://fykq.appldkj.com/api/jeecg-boot/app/card/goodfishOrder/queryByOrderNo', orderNo)
};

module.exports = {
	API: API
};